home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Toolbox
/
Visual Basic Toolbox (P.I.E.)(1996).ISO
/
dde
/
odbcncap
/
cts.bas
< prev
next >
Wrap
BASIC Source File
|
1995-10-26
|
3KB
|
101 lines
Option Explicit
Function LoadMainListBox (frmForm As Form) As Integer
Dim nStatus As Integer
Dim sSiteId As String
Dim sSiteNbr As String
Dim sCity As String
Dim sState As String
Dim workString As String
Dim sSourceSQL As String
Dim i As Integer
' Hope for the best!
LoadMainListBox = True
frmForm!lstSites.Clear
If ghenv = 0 Then
InitializeDatabaseConnection
End If
If ghStmt = 0 Then
nStatus = SQLAllocStmt(ghDbc, ghStmt)
If nStatus <> SQL_SUCCESS And nStatus <> SQL_SUCCESS_WITH_INFO Then
DescribeError ghDbc, ghStmt
LoadMainListBox = False
Exit Function
End If
End If
sSourceSQL = "select a.SITE_SYSGEN_ID, a.SITE_NBR, a.CITY_NAME, a.STATE_CODE"
sSourceSQL = sSourceSQL & " from SITE_T a"
sSourceSQL = sSourceSQL & " where a.CITY_NAME like ? "
sSourceSQL = sSourceSQL & " and a.STATE_CODE = ? "
sSourceSQL = sSourceSQL & " and a.SITE_SYSGEN_ID > ? "
ODBCBuildParams SQL_C_CHAR, SQL_CHAR, "San%", 4, 0, 1
ODBCBuildParams SQL_C_CHAR, SQL_CHAR, "CA", 2, 0, 2
ODBCBuildParams SQL_C_LONG, SQL_INTEGER, CInt(400), 5, 0, 3
nStatus = ODBCExecute(ghDbc, ghStmt, sSourceSQL, aParmList())
If nStatus <> True Then
LoadMainListBox = False
Exit Function
End If
waitcursor True
Do
nStatus = SQLFetch(ghStmt)
If nStatus = SQL_NO_DATA_FOUND Then
Exit Do
Else
If nStatus <> SQL_SUCCESS Then
DescribeError ghDbc, ghStmt
LoadMainListBox = False
Exit Do
End If
End If
sSiteId = GetODBCWorkString(ghDbc, ghStmt, 1)
sSiteNbr = GetODBCWorkString(ghDbc, ghStmt, 2)
sCity = GetODBCWorkString(ghDbc, ghStmt, 3)
sState = GetODBCWorkString(ghDbc, ghStmt, 4)
workString = sSiteId & " " & sSiteNbr & " " & sCity & ", " & sState
frmForm!lstSites.AddItem workString
Loop
nStatus = SQLFreeStmt(ghStmt, SQL_CLOSE)
sSourceSQL = "select max(a.SITE_SYSGEN_ID)"
sSourceSQL = sSourceSQL & " from SITE_T a"
'
' For a non-parameterized call, you must call the
' function with zeros to reset the parameter array.
'
ODBCBuildParams 0, 0, 0, 0, 0, 0
nStatus = ODBCExecute(ghDbc, ghStmt, sSourceSQL, aParmList())
If nStatus <> True Then
LoadMainListBox = False
GoTo FormLoad_Continue
End If
nStatus = SQLFetch(ghStmt)
If nStatus = SQL_SUCCESS Or nStatus = SQL_SUCCESS_WITH_INFO Then
sSiteId = GetODBCWorkString(ghDbc, ghStmt, 1)
frmForm!txtText1.Text = sSiteId
Else
If nStatus <> SQL_NO_DATA_FOUND Then
DescribeError ghDbc, ghStmt
LoadMainListBox = False
End If
End If
nStatus = SQLFreeStmt(ghStmt, SQL_CLOSE)
FormLoad_Continue:
'*** let's clean up after ourselves and free up some memory for this statement
waitcursor False
End Function